﻿Public Class frmReport

    ''' <summary>
    ''' Thuộc tính lưu tiêu đề của form khi được hiển thị
    ''' </summary>
    ''' <remarks>Nguyễn Huy Thường added on 16/11/2010</remarks>
    Private m_Title As String
    Public Property Title() As String
        Get
            Return m_Title
        End Get
        Set(ByVal value As String)
            m_Title = value
        End Set
    End Property

    ''' <summary>
    ''' Thuộc tính lưu loại báo cáo sẽ được hiển thị
    ''' </summary>
    ''' <remarks>Nguyễn Huy Thường added on 16/11/2010</remarks>
    Private m_ReportType As clscommon.ReportType
    Public Property ReportType() As clscommon.ReportType
        Get
            Return m_ReportType
        End Get
        Set(ByVal value As clscommon.ReportType)
            m_ReportType = value
        End Set
    End Property

    ''' <summary>
    ''' Thuộc tính lưu nguồn dữ liệu để fill vào report
    ''' </summary>
    ''' <remarks>Nguyễn Huy Thường added on 16/11/2010</remarks>
    Private m_DataSource As DataTable
    Public Property DataSource() As DataTable
        Get
            Return m_DataSource
        End Get
        Set(ByVal value As DataTable)
            m_DataSource = value
        End Set
    End Property

    ''' <summary>
    ''' Thuộc tính lưu các giá trị truyền vào báo cáo
    ''' </summary>
    ''' <remarks>Nguyễn Huy Thường added on 16/11/2010</remarks>
    Private m_Parameter As String
    Public Property Parameter() As String
        Get
            Return m_Parameter
        End Get
        Set(ByVal value As String)
            m_Parameter = value
        End Set
    End Property

    ''' <summary>
    ''' Sub thực hiện việc hiển thị report
    ''' </summary>
    ''' <remarks>Nguyễn Huy Thường added on 16/11/2010</remarks>
    Private Sub ShowReport()
        If ReportType = clscommon.ReportType.AvailableItem Then
            Dim availableItemList As New AvailableItemList
            availableItemList.SetDataSource(DataSource)
            crvReport.ReportSource = availableItemList
        ElseIf ReportType = clscommon.ReportType.AllItem Then
            Dim allItemList As New AllItemList
            allItemList.SetDataSource(DataSource)
            crvReport.ReportSource = allItemList
        End If
    End Sub

    ''' <summary>
    ''' Gọi sub ShowReport() khi form được load
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks>Nguyễn Huy Thường added on 16/11/2010</remarks>
    Private Sub frmBaseShow_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Me.Title = Title
            ShowReport()
        Catch ex As Exception
            clscommon.ShowException(ex.Message)
        End Try
    End Sub
End Class